﻿using C1.Win.C1Ribbon;
using CWCS.BLL;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace CWCS.UI
{
    public partial class FrmLogIn : C1RibbonForm
    {
        public static string username = "";
        public BLL.ConveryBLL bLL = new ConveryBLL();
        public FrmLogIn()
        {
            InitializeComponent();
        }


        private void btnConfirm_Click(object sender, EventArgs e)
        {
            try
            {
                if (bLL.CheckUserInfo(txt_password.Text, ref username))
                {
                    BLLBase.user = username;
                    BLLBase.loginFlag = true;
                    BLLBase.loginTime = System.DateTime.Now;
                }
                this.Close();
            }
            catch { }
        }
        private void btnKeyPress(object sender, KeyPressEventArgs e)
        {
            try
            {
                if (e.KeyChar == '\r')
                {
                    if (bLL.CheckUserInfo(txt_password.Text, ref username))
                    {
                        BLLBase.user = username;
                        BLLBase.loginFlag = true;
                        BLLBase.loginTime = System.DateTime.Now;
                    }
                    this.Close();
                }
            }
            catch { }
        }
        private DateTime downTime;
        private void btnKeyDown(object sender, KeyEventArgs e)
        {
            downTime = DateTime.Now;
        }
        /*private void btnKeyUp(object sender, KeyEventArgs e)
        {
            if (e.KeyValue.ToString() == "34")  //键盘上的"PgDn"键
            {
                BLLBase.user = "今天国际调试人员";
                BLLBase.loginFlag = true;
                BLLBase.loginTime = System.DateTime.Now;
                this.Close();
            }
            else
            {
                DateTime upTime = DateTime.Now;
                TimeSpan ts = upTime.Subtract(downTime);
                if (ts.Milliseconds > 20)
                {
                    txt_password.Text = "";
                    MessageBox.Show("禁止手动输入密码!");
                }
                else
                {
                    if (e.KeyValue == '\r')
                    {
                        if (bLL.CheckUserInfo(txt_password.Text, ref username))
                        {
                            BLLBase.user = username;
                            BLLBase.loginFlag = true;
                            BLLBase.loginTime = System.DateTime.Now;
                        }
                        this.Close();
                    }
                }
            }
        }*/
        private void btnCancle_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
